<template>
  <div class="collect">
    <div class="collectTop">
      <span
        class="iconfont icon-xiazai6 icona"
        @click="$router.go(-1)"
      ></span>
      <!-- <span>我的收藏</span> -->
    </div>
    <van-tabs v-model="active">
      <van-tab title="歌手">
        <ul>
          <li v-for="item in Sublist" :key="item.id">
            <div class="vanImg">
              <img :src="item.img1v1Url" alt="" />
            </div>
            <p>{{ item.name }}</p>
            <!-- <span :class="['iconfont', item.followed?'icon-yiguanzhu1':'icon-guanzhu']" @click="followed(index)"></span> -->
          </li>
        </ul>
      </van-tab>
      <van-tab title="MV">
        <div class="collectMv" v-for="item in mvSublist" :key="item.id">
          <router-link
            tag="div"
            class="collectImg"
            :to="'/recommend/videolist?id=' + item.vid"
          >
            <img :src="item.coverUrl" alt="" />
          </router-link>
          <div class="collectName">
            <h4>{{ item.title }}</h4>
            <p v-for="val in item.creator" :key="val.userId">
              {{ val.userName }}
            </p>
            <!-- <p>时间</p> -->
          </div>
        </div>

        <!-- 推荐视频 -->
        <div class="recommendVideo" v-show="list">
          <div class="recommendVideoTop">
            <h1>为你推荐</h1>
            <div class="icona" @click="remove"><span class="iconfont icon-shanchu"></span></div>
          </div>
          <div class="recommendVideoBottom">
            <div
              class="recommendVideoBottomlist"
              v-for="item in relatedAllvideo"
              :key="item.vid"
            >
              <router-link tag="div" class="recommendVideoImg" :to="'/recommend/videolist?id=' + item.vid">
                <img :src="item.coverUrl" alt="" />
              </router-link>
              <div class="collectName">
                <h4>{{ item.title }}</h4>
                <p v-for="val in item.creator" :key="val.userId">
                  {{ val.userName }}
                </p>
                <!-- <p>时间</p> -->
              </div>
            </div>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import {
  getArtistSublist,
  getMvSublist,
  getRelatedAllvideo,
} from "../../api/user";
export default {
  data() {
    return {
      list:true,
      active: 0,
      Sublist: [], //收藏的歌手
      mvSublist: [], //收藏的MV
      mvSublistId: null, //收藏MV的id
      relatedAllvideo: [], //推荐的视频
    };
  },
  methods:{
    remove(){
      // console.log('点击了');
      this.list = false;

    }
  },
  created() {
    getArtistSublist().then((data) => {
      this.Sublist = data.data;
      // console.log(this.Sublist);
    });
    getMvSublist().then((data) => {
      this.mvSublist = data.data;
      this.mvSublist.forEach((item) => {
        this.mvSublistId = item.vid;
          // console.log(this.mvSublistId);
          getRelatedAllvideo({ id:item.vid }).then((data) => {
          //  console.log(data);
          this.relatedAllvideo = data.data;
           });
      });
    });
  },
};
</script>

<style lang="less">
.collect {
  padding: 15px;
  .collectTop {
    position: relative;
    width: 100%;
    height: 22px;
    .icona {
      font-size: 18px;
    }
    .icon {
      position: absolute;
      top: 0px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 20px;
    }
  }
  ul {
    li {
      height: 50px;
      border-bottom: 2px solid #f8f8f8;
      padding: 9px;
      display: flex;
      position: relative;
      .vanImg {
        width: 49px;
        height: 49px;
        border-radius: 50%;
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }
      p {
        margin: auto 13px;
      }
      span {
        position: absolute;
        top: 50%;
        right: 11px;
        transform: translateY(-50%);
      }
    }
  }
  .collectMv {
    height: 84px;
    // width: 100%;
    padding: 10px 12px;
    display: flex;
    .collectImg {
      width: 153px;
      height: 100%;
      border-radius: 8px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 8px;
      }
    }
    .collectName {
      flex: 1;
      margin-left: 10px;
      h4 {
        margin: 6px 0px;
        font-size: 16px;
        font-weight: 500;
      }
      p {
        font-size: 12px;
        color: #939393;
        margin: 3px 0px;
      }
    }
  }
  .recommendVideo {
    margin-top: 8px;
    .recommendVideoTop {
      display: flex;
      position: relative;
      h1 {
        font-size: 20px;
      }
      .icona {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background-color: #f2f2f2;
        position: absolute;
        top: 50%;
        right: 0px;
        transform: translateY(-50%);
        font-size: 18px;
        span {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          font-size: 18px;
        }
      }
    }
    .recommendVideoBottom {
      margin-top: 18px;
      .recommendVideoBottomlist {
        height: 84px;
        padding: 10px 12px;
        display: flex;
        .recommendVideoImg {
          width: 153px;
          height: 100%;
          border-radius: 8px;
          img {
            width: 100%;
            height: 100%;
            border-radius: 8px;
          }
        }
        .collectName {
          flex: 1;
          margin-left: 10px;
          h4 {
            margin: 6px 0px;
            font-size: 16px;
            font-weight: 500;
          }
          p {
            font-size: 12px;
            color: #939393;
            margin: 3px 0px;
          }
        }
      }
    }
  }
}
</style>